// 字符串中的单词数
/**
 * @param {string} s
 * @return {number}
 */
 var countSegments = function(s) {
    let ans = 0, last = " ";
        for(let c of s){
            //console.log(c);
            if(c == " " && last != " ")
                ans++;
            last = c;
        }
        return last == " " ? ans : ans + 1;
    };